package com.rabincorp.facepoll.application;

import com.rabincorp.facepoll.domain.services.poll.PollService;
import com.rabincorp.facepoll.dto.PollQuestionDTO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.mvc.SimpleFormController;

/** 
 *
 * @author isakrabin
 */
@Controller
public class CreatePollController extends SimpleFormController {

    private final static Log LOGGER = LogFactory.getLog(CreatePollController.class);
    @Autowired
    private PollService pollService;

    public CreatePollController() {
    }

    @Override
    protected void doSubmitAction(Object command) throws Exception {
        LOGGER.info("Processing Form");
        PollQuestionDTO pollQuestionDTO = (PollQuestionDTO) command;
        pollService.create(pollQuestionDTO.getTitle(), pollQuestionDTO.getQuestion(), pollQuestionDTO.getOptions(), Boolean.TRUE, FacepollConstant.PollType.PUBLIC, null, null, 1L);

    }
}
